/*
 * @Author: 
 * @Date: 2025-02-08 18:00:24
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2025-02-08 18:02:22
 * @Description: 
 */
import { Provide, Inject } from '@midwayjs/core';
import { Controller, Post, Get, Put, Del, Query, Body, Param } from '@midwayjs/decorator';
import { DPChangeSampleDetailService } from '../service/sampleDetial.service';
import { DPChangeSampleDetailCreateDto, DPChangeSampleDetailUpdateDto, DPChangeSampleDetailQueryDto, DPChangeSampleDetailDeleteDto } from '../dto/sampleDetial.dto';

@Provide()
@Controller('/sample-detail')
export class DPChangeSampleDetailController {

  @Inject()
  sampleDetailService: DPChangeSampleDetailService;

  // 添加样本详情
  @Post('/add')
  async addSampleDetail(@Body() createDto: DPChangeSampleDetailCreateDto) {
    const result = await this.sampleDetailService.addSampleDetail(createDto);
    return result;
  }

  // 获取所有样本详情
  @Get('/all')
  async getAllSampleDetails() {
    const result = await this.sampleDetailService.getAllSampleDetails();
    return result;
  }

  // 根据查询条件获取样本详情，支持分页
  @Get('/query')
  async querySampleDetails(@Query() queryDto: DPChangeSampleDetailQueryDto) {
    const result = await this.sampleDetailService.findSampleDetails(queryDto);
    return result;
  }

  // 删除样本详情
  @Del('/:id')
  async deleteSampleDetail(@Param() params: { id: number }) {
    const result = await this.sampleDetailService.deleteSampleDetail(params.id);
    return result;
  }

  // 批量更新样本详情
  @Put('/batch-update')
  async batchUpdateSampleDetails(
    @Body() updateData: DPChangeSampleDetailUpdateDto,
    @Query('sampleIds') sampleIds: number[]
  ) {
    const result = await this.sampleDetailService.batchUpdateSampleDetails(sampleIds, updateData);
    return result;
  }
}
